package com.qd.common.panda.domain.entity.space;

import com.cdqidi.util.page.BaseQuery;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.qd.common.panda.domain.entity.info.ParkInfoPicDTO;
import com.qd.common.panda.domain.entity.info.ParkInfoPropertyRightDTO;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;

/**
 * 车位租赁信息,车主端显示
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class CarOwnerParkSpaceDTO extends BaseQuery {

    /**
     * 租赁ID
     */
    private String sid;
    /**
     * 承租信息ID
     */
    private String id;
    /**
     * 可租赁开始时间
     */
    private String leasableStartDate;
    /**
     * 可租赁结束时间
     */
    private String leasableEndDate;
    /**
     * 可租赁开始小时
     */
    private String leasableStartHour;
    /**
     * 可租赁结束小时
     */
    private String leasableEndHour;
    /**
     * 租赁类型
     */
    private String leaseType;
    /**
     * 租赁类型显示
     */
    private String leaseTypeDisplay;
    /**
     * 租赁开始时间
     */
    private String startDate;
    /**
     * 租赁结束时间
     */
    private String endDate;
    /**
     * 停车场ID
     */
    private String parkId;
    /**
     * 停车场ID显示
     */
    private String parkIdDisplay;
    /**
     * 车位ID
     */
    private String aid;
    /**
     * 是否结束
     */
    private String end;
    /**
     * 是否结束显示
     */
    private String endDisplay;
    /**
     * 租赁人车牌号
     */
    private String tenantNumber;
    /**
     * 车位号
     */
    private String spaceNumber;
    /**
     * 熊猫泊车车位号
     */
    private String sysSpaceNumber;
    /**
     * 车位平面图
     */
    private String planPic;
    /**
     * 是否可租
     */
    private String rentable;
    /**
     * 是否可租显示
     */
    private String rentableDisplay;
    /**
     * 所在地区
     */
    private String region;
    /**
     * 停车场位置
     */
    private String address;
    /**
     * 车位位置说明
     */
    private String note;
    /**
     * 日收益
     */
    @JsonIgnore
    private BigDecimal expectedDayRevenue;
    /**
     * 日收益显示
     */
    private String expectedDayRevenueDisplay;
    /**
     * 车牌号
     */
    private List<String> parkNumberList;
    /**
     * 租赁日期列表
     */
    private List<ParkSpaceDateDTO> dateList;
    /**
     * 车位照片
     */
    private List<ParkInfoPicDTO> picList;
    /**
     * 车位产权
     */
    private List<ParkInfoPropertyRightDTO> propertyRightList;

    public String getExpectedDayRevenueDisplay() {
        return Optional.ofNullable(expectedDayRevenue).orElse(BigDecimal.valueOf(0)).stripTrailingZeros().toPlainString();
    }

    @Override
    public void freeData() {
        this.sid = null;
        this.id = null;
        this.leasableStartDate = null;
        this.leasableEndDate = null;
        this.leasableStartHour = null;
        this.leasableEndHour = null;
        this.leaseType = null;
        this.leaseTypeDisplay = null;
        this.startDate = null;
        this.endDate = null;
        this.end = null;
        this.endDisplay = null;
        this.tenantNumber = null;
        this.spaceNumber = null;
        this.sysSpaceNumber = null;
        this.rentableDisplay = null;
        this.region = null;
        this.address = null;
        this.note = null;
        this.parkId = null;
        this.parkIdDisplay = null;
        this.expectedDayRevenue = null;
        this.expectedDayRevenueDisplay = null;
        Optional.ofNullable(parkNumberList).ifPresent(List::clear);
        Optional.ofNullable(dateList).ifPresent(List::clear);
        Optional.ofNullable(picList).ifPresent(List::clear);
        Optional.ofNullable(propertyRightList).ifPresent(List::clear);
        super.freeData();
    }
}
